]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
St: add :disabled pseudo class when a button is not reactive
authorGiovanni Campagna <gcampagna@src.gnome.org>
Wed, 18 Jul 2012 11:59:26 +0000 (13:59 +0200)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Sat, 21 Jul 2012 13:40:28 +0000 (15:40 +0200)
The :reactive property is used on StButton to like the :sensitive
property on GtkWidgets, that is, to indicate that the user is not
(yet) expected to click the button, and therefore should affect
styling too.
This allows to remove some code at the JS layer.

https://bugzilla.gnome.org/show_bug.cgi?id=619955

js/ui/networkAgent.js
src/st/st-button.c

index c9473a7668d51af06717baffe61c6efe1e2b7649..1c29b98f353bf0ffeb167b4c0523bf6c22e1b393 100644 (file)
@@ -166,10 +166,6 @@ const NetworkSecretDialog = new Lang.Class({
 
         this._okButton.button.reactive = valid;
         this._okButton.button.can_focus = valid;
-        if (valid)
-            this._okButton.button.remove_style_pseudo_class('disabled');
-        else
-            this._okButton.button.add_style_pseudo_class('disabled');
     },
 
     _onOk: function() {
index a4edbe75a57d118b112f607091456876362e42d6..e3c46f9fb9e960fee1bccd0abec48f26efed5c05 100644 (file)
@@ -446,6 +446,15 @@ st_button_class_init (StButtonClass *klass)
                   G_TYPE_INT);
 }
 
+static void
+notify_reactive_cb (StWidget *button)
+{
+  if (clutter_actor_get_reactive (CLUTTER_ACTOR (button)))
+    st_widget_remove_style_pseudo_class (button, "disabled");
+  else
+    st_widget_add_style_pseudo_class (button, "disabled");
+}
+
 static void
 st_button_init (StButton *button)
 {
@@ -455,6 +464,9 @@ st_button_init (StButton *button)
 
   clutter_actor_set_reactive (CLUTTER_ACTOR (button), TRUE);
   st_widget_set_track_hover (ST_WIDGET (button), TRUE);
+
+  g_signal_connect(button, "notify::reactive",
+                   G_CALLBACK (notify_reactive_cb), NULL);
 }
 
 /**